package com.xkcyy.one.controller;

import com.xkcyy.one.common.Result;
import com.xkcyy.one.entity.TrainingSession;
import com.xkcyy.one.service.TrainingSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 训练会话控制器
 */
@RestController
@RequestMapping("/api/training/sessions")
public class TrainingSessionController {
    
    private final TrainingSessionService trainingSessionService;
    
    @Autowired
    public TrainingSessionController(TrainingSessionService trainingSessionService) {
        this.trainingSessionService = trainingSessionService;
    }
    
    /**
     * 根据训练ID获取会话列表
     *
     * @param trainingId 训练ID
     * @return 会话列表
     */
    @GetMapping("/training")
    public Result<List<TrainingSession>> getSessionsByTrainingId(@RequestParam Long trainingId) {
        return Result.success(trainingSessionService.getSessionsByTrainingId(trainingId));
    }
    
    /**
     * 根据ID获取会话
     *
     * @param id 会话ID
     * @return 会话信息
     */
    @GetMapping("/get")
    public Result<TrainingSession> getSessionById(@RequestParam Long id) {
        return Result.success(trainingSessionService.getSessionById(id));
    }
} 